home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1593 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.6 KB

  1. Path: library.erc.clarkson.edu!rpi!not-for-mail
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.lang.c++.moderated,comp.lang.c++
  4. Subject: Re: Meaning of the specifier volatile?
  5. Followup-To: comp.lang.c++.moderated,comp.lang.c++
  6. Date: 11 Jan 1996 17:31:53 -0000
  7. Organization: GABI Software, Sarl.
  8. Sender: cppmods@netlab.cs.rpi.edu
  9. Approved: vandevod@cs.rpi.edu
  10. Message-ID: <4d3hi9$qe2@netlab.cs.rpi.edu>
  11. References: <4c9740$27n@netlab.cs.rpi.edu> <4cff74$gfj@netlab.cs.rpi.edu> <4cj5u4$qjm@netlab.cs.rpi.edu> <4cree9$9bv@netlab.cs.rpi.edu>
  12. NNTP-Posting-Host: netlab.cs.rpi.edu
  13.  
  14. X-Original-Date: 11 Jan 1996 12:45:44 +0100
  15.  
  16. Tom Payne (thp@cs.ucr.edu) wrote:
  17.  
  18. |> J. Kanze (kanze@gabi-soft.fr) wrote:
  19. |> [stuff deleted]
  20. |> : On point concerning volatile that I have not seen made is the fact that
  21. |> : the C/C++ concept of volatile is orthogonal to atomicity of access.
  22. |> : Declaring an object volatile is *NOT* sufficient with regards to
  23. |> : asynchronous events; the object must still be of a type for which the
  24. |> : compiler will generate atomic accesses.  
  25. |> [stuff deleted]
  26.  
  27. |> Because of the signal-handlers-can't-read provision of the ANSI C
  28. |> standard, atomicity is unnecessary in the coordination of asynchronous
  29. |> activity for programs with defined behavior:
  30.  
  31. |>   *  signal handlers won't read any partially written non-atomic 
  32. |>      shared variables, because they are not allowed to read variables 
  33. |>      of static storage class in programs with defined behavior.
  34.  
  35. |>   *  the program itself won't read any partially written non-atomic 
  36. |>      shared varible, because signal handlers don't return control 
  37. |>      until they have completed their writes of volatile variables.
  38.  
  39. Close.  The program itself won't read any partially written non-atomic
  40. shared variables, because signal handlers are not allowed to write such
  41. variables in programs with defined behavior.
  42.  
  43. Note that your statement, if allowed, could lead to anomalies if a
  44. non-atomic read is interrupted, and the signal handler writes the
  45. object.  The first part of the read sees the old value, and the second
  46. part the new value.
  47. -- 
  48. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  49. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  50. Conseils, itudes et rialisations en logiciel orienti objet --
  51.               -- A la recherche d'une activiti dans une region francophone
  52.  
  53.     [ comp.lang.c++.moderated is a moderated newsgroup.  Submit articles ]
  54.     [  to <c++-submit@netlab.cs.rpi.edu>.  The moderation policy can be  ]
  55.     [   retrieved from <http://netlab.cs.rpi.edu/~cppmods/guide.html>.   ]
  56.     [    Moderators can be reached at: c++-request@netlab.cs.rpi.edu.    ]
  57.